#!/bin/bash

# 定义变量方便修改
table_db=cy_database
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else
	do_date=`date -d "-1 day" +%F`
fi

sql="
with
tmp1_table as
(
select
	job_fair_name,
	hold_date,
	enterprise_sum as ent_num,
	position_sum,
	admission_sum,
	cast(current_date() as string) as operate_time
from cy_database.dws_job_fair
order by hold_date desc
limit 10
)

insert overwrite table cy_database.ads_big_screen_result_new_job_fair
select job_fair_name,hold_date,ent_num,position_sum,admission_sum,operate_time from tmp1_table

;
"

$hive -e "$sql"